﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using Vit.Web;
using Vit.Web.Mvc.DataAnnotations;
using Vit.Web.Models;

namespace Vit.Web.Models
{
    public class Role
    {
        public Role()
        {
            ChildRoles = new List<Role>();
            Permissions = new List<Permission>();
            Users = new List<User>();
        }

        [Key]
        [StringLength(50)]
        [ShowFor(ShowForFilter = true)]
        [Remote("RoleExists", "Role", ErrorMessage = "Role_Duplicated")]
        public string Name { get; set; }

        [ScriptIgnore]
        [XmlIgnore]
        public virtual Role ParentRole { get; set; }
        [ScriptIgnore]
        [XmlIgnore]
        public virtual ICollection<Role> ChildRoles { get; set; }
        [ScriptIgnore]
        [XmlIgnore]
        public virtual ICollection<Permission> Permissions { get; set; }
        [ScriptIgnore]
        [XmlIgnore]
        public virtual ICollection<User> Users { get; set; }
        [ScriptIgnore]
        [XmlIgnore]
        public virtual WebSite Site { get; set; }
    }
}
